…extension`)
Here's an optimized version of your program.
Main changes.
- Replace slices and length-based for-loops with more direct, idiomatic Python control flow (they did nothing).
- Combine checks for better early returns.
- Reduce unnecessary list accesses.
- Process decorator list without unnecessary nesting.
- No changes to function signatures or output.
All your in-code comments are preserved (there were none).
**Key improvements:**
- Direct mapping of `parents[0].type`; no useless range-loop.
- Early exit for empty `parents`.
- Avoid redundant list traversal.
- Set literal for type checking.
This function has the same return signature and logic, but runs faster and is easier to reason about.
PR Type
Enhancement
Description
Integrate LSP server for function optimization
Define LSP methods for optimization workflow
Modularize & refactor FunctionOptimizer methods
Introduce benchmark and test discovery utilities
Changes walkthrough 📝
beta.py
Implement LSP optimization endpointscodeflash/lsp/beta.py
server.py
Add custom LSP server protocol and initializationcodeflash/lsp/server.py
pyproject.tomlfor optimizerfunction_optimizer.py
Modularize FunctionOptimizer methodscodeflash/optimization/function_optimizer.py
can_be_optimizedhelper methodoptimize_functionto use new stepsoptimizer.py
Enhance Optimizer with LSP integrationcodeflash/optimization/optimizer.py
run_benchmarksanddiscover_testsprepare_module_for_optimizationhelpercreate_function_optimizersignaturepyproject.toml
Update dependencies and lint ignorepyproject.toml
pygls